package org.example.gradle.jp.feigns.fallback;

import gradle.common.core.response.ServerResponse;
import lombok.extern.slf4j.Slf4j;
import org.example.gradle.jp.feigns.GradleAdminFeignClient;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * fallback
 */
@Slf4j
@Component
public class GradleAdminFallbackFactory implements FallbackFactory<GradleAdminFeignClient> {

    @Override
    public GradleAdminFeignClient create(Throwable cause) {

        return new GradleAdminFeignClient() {

            @Override
            public ServerResponse addUser() {
                log.error("【admin-service】 GradleOrderFeignClient addUster() exception = {}", cause.getMessage());
                return ServerResponse.error("error");
            }
        };
    }
}
